<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>全屏不全屏</title>
</head>
<body>
<button id="fullScreen">全屏模式</button>
<button id="noFullScreen">取消全屏</button>
</body>
</html>
<script>

    // 全屏的API
    // 全屏是否可用：Document.fullscreenEnabled
    // 开启全屏：Document.requestFullScreen()
    // 退出全屏：Document.exitFullscreen()
    // 获取全屏元素：document.mozFullScreenElement
    // 监听全屏模式变化: fullscreenchange
    //

    document.getElementById("fullScreen").onclick=function(){
        if(document.documentElement.RequestFullScreen){
            document.documentElement.RequestFullScreen();
        }
        //兼容火狐
        console.log(document.documentElement.mozRequestFullScreen)
        if(document.documentElement.mozRequestFullScreen){
            document.documentElement.mozRequestFullScreen();
        }
        //兼容谷歌等可以webkitRequestFullScreen也可以webkitRequestFullscreen
        if(document.documentElement.webkitRequestFullScreen){
            document.documentElement.webkitRequestFullScreen();
        }
        //兼容IE,只能写msRequestFullscreen
        if(document.documentElement.msRequestFullscreen){
            document.documentElement.msRequestFullscreen();
        }
    }
    document.getElementById("noFullScreen").onclick=function(){
        if(document.exitFullScreen){
            document.exitFullscreen()
        }
        //兼容火狐
        console.log(document.mozExitFullScreen)
        if(document.mozCancelFullScreen){
            document.mozCancelFullScreen()
        }
        //兼容谷歌等
        if(document.webkitExitFullscreen){
            document.webkitExitFullscreen()
        }
        //兼容IE
        if(document.msExitFullscreen){
            document.msExitFullscreen()
        }
    }
</script>
